package com.atguigu.lease.common.exception;

import com.atguigu.lease.common.result.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(value = Exception.class)
    @ResponseBody
    public Result handleException(Exception e) {

        e.printStackTrace();
        return Result.fail();

    }
    @ExceptionHandler(LeaseExcetion.class)
    @ResponseBody
    public Result handle(LeaseExcetion ex) {
        ex.printStackTrace();
        return Result.fail(ex.getCode(),ex.getMessage());

    }
}
